package whut.edu.lambda;

import java.util.Random;

public class LambdaTest04 {
    public static void main(String[] args) {
        useRandomInter(new RandomInter() {
            @Override
            public int getNumber() {
                Random re = new Random();
                int num = re.nextInt(100)+1;
                return num;
            }
        });

        useRandomInter(()->
            new Random().nextInt(100)+1
        );

    }
    public static void useRandomInter(RandomInter randomInter){
        //走的是重写后的方法逻辑，用result接收，再打印
        int result = randomInter.getNumber();
        System.out.println(result);
    }
}

interface RandomInter{
    int getNumber();
}